# night-sky server Makefile
# 
# @author krdlab
# @refer  http://www-or.amp.i.kyoto-u.ac.jp/algo-eng/db/makefile.html

# XXX 整理しないとなー．

SRCS = night-sky.cpp server.cpp logger.cpp socket.cpp options.cpp
OBJS = $(SRCS:.cpp=.o)

### command and flags ###
# uncomment when debugging
#DEBUG	= -ggdb -pg # -lefence

# common (*.o)
LD	= gcc
LDFLAGS	= -g $(DEBUG)
LDLIBS	= -lm -lpthread -llog4cxx

# C (*.c)
CC	= gcc
CFLAGS	= -g -O2 -Wall $(DEBUG)
CPPFLAGS= -I./src

# C++ (*.cpp)
CXX	= g++
CXXFLAGS= -g -O2 -Wall $(DEBUG)

### rules ###

.PHONY: all
all: night-sky

.PHONY: night-sky
night-sky: $(OBJS)
	g++ ./bin/*.o -o ./bin/night-sky $(LDLIBS)
	cp -a ./conf/log4j.xml ./bin/

night-sky.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o ./bin/night-sky.o ./src/night-sky.cpp

server.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o ./bin/server.o ./src/server.cpp

logger.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o ./bin/logger.o ./src/logger.cpp

socket.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o ./bin/socket.o ./src/socket.cpp

options.o:
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o ./bin/options.o ./src/options.cpp

.PHONY: clean
clean:
	rm bin/*
